/** COPYRIGHT(C) 2008. Loc Phan. All Rights Reserved.
    A component class that take in the number of circles
    and draw them with random coordinate and radius.
    @author Loc Phan
    @version 1.01 2008-10-28
*/

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.util.Random;

import javax.swing.JComponent;

public class RandomCircleComponent extends JComponent 
{
   /**Constructs an RandomCircleComponent object
    * 
    * @param num_circle Number of circle(s)
    */
   public RandomCircleComponent(int num_circle)
   {
      circle = num_circle;
   }
   /**Draws circles
    * 
    */
   public void paint(Graphics g)
	   {
	     Graphics2D g2 = (Graphics2D) g; 

	     Random coordinate = new Random();
	     
	     for(int i=0;i<circle;i++)
	     {
	        int x = coordinate.nextInt(300)+10;
	        int y = coordinate.nextInt(250)+10;
	        int r = coordinate.nextInt(90);
	        Ellipse2D circle = new Ellipse2D.Double(x,y,r,r);
	        g2.draw(circle);
	     }
	     
	   }
	private int circle;
}
